/*
 * @(#) PublicEvaServiceImpl.java 2011-9-28
 *
 * Copyright (c) 2011, Strong Technology. All Rights Reserved.
 * Strong Technology. CONFIDENTIAL
 */
package cn.strong.gweva.publiceva.business.service.impl;

import java.math.BigDecimal;
import java.util.Date;

import cn.strong.gweva.common.business.entity.db.JxkhPublicRuleEntity;
import cn.strong.gweva.common.business.service.impl.AbstractServiceImpl;
import cn.strong.gweva.common.util.CodeBook;
import cn.strong.gweva.common.util.Constants;
import cn.strong.gweva.common.util.Constants4Method;
import cn.strong.gweva.publiceva.business.entity.PublicEvaEntity;
import cn.strong.gweva.publiceva.business.service.PublicEvaService;


/**
 * 公共考核。
 * 
 * @author lilanfei
 * @version 1.0
 * @since 2011-9-28
 */
public class PublicEvaServiceImpl extends AbstractServiceImpl implements PublicEvaService
{
	/**
	 * 录入公共考核.
	 * 
	 * @param publicEvaEntity 公共考核录入entity
	 * @throws Exception 异常
	 */
	public void insertPublicEva(PublicEvaEntity publicEvaEntity) throws Exception
	{
		JxkhPublicRuleEntity rule = (JxkhPublicRuleEntity)this.getCommonDao().searchObj(
				Constants4Method.PUBLICEVA_SELECT_PUBLIC_RULE_BY_ID, publicEvaEntity.getRuleId());
		
		if (rule != null)
		{
			// 分数
			if (CodeBook.IS_BASE_TOTAL.YES.getCode().equals(rule.getIsBaseTotal()))
			{
				publicEvaEntity.setScore(new BigDecimal(0));
			}
			else
			{
				publicEvaEntity.setScore(rule.getScore());
			}
			// 考核类型
			publicEvaEntity.setType(Constants.EVA_TYPE_PUBLIC);
			// 是否自动计算
			publicEvaEntity.setIsAuto(CodeBook.IS_AUTO.NO.getCode());
			// 是否删除
			publicEvaEntity.setDelFlag(Constants.DEL_FLAG_NO);
			// 更新时间
			publicEvaEntity.setUpdateTime(new Date());
			this.getCommonDao().insert(Constants4Method.PUBLICEVA_INSERT_JXKH_RESULT, publicEvaEntity);
		}
	}
}
